home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / token.h < prev    next >
C/C++ Source or Header  |  1997-03-07  |  2KB  |  112 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_token_h)
  24. #define octave_token_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include <string>
  31.  
  32. class symbol_record;
  33.  
  34. class
  35. token
  36. {
  37. public:
  38.   enum token_type
  39.     {
  40.       generic_token,
  41.       string_token,
  42.       double_token,
  43.       ettype_token,
  44.       pttype_token,
  45.       sym_rec_token,
  46.     };
  47.  
  48.   enum end_tok_type
  49.     {
  50.       simple_end,
  51.       for_end,
  52.       function_end,
  53.       if_end,
  54.       switch_end,
  55.       while_end,
  56.       try_catch_end,
  57.       unwind_protect_end,
  58.     };
  59.  
  60.   enum plot_tok_type
  61.     {
  62.       replot = 1,
  63.       two_dee = 2,
  64.       three_dee = 3,
  65.     };
  66.  
  67.   token (int l = -1, int c = -1);
  68.   token (const string& s, int l = -1, int c = -1);
  69.   token (double d, const string& s = string (), int l = -1, int c = -1);
  70.   token (end_tok_type t, int l = -1, int c = -1);
  71.   token (plot_tok_type t, int l = -1, int c = -1);
  72.   token (symbol_record *s, int l = -1, int c = -1);
  73.  
  74.   ~token (void);
  75.  
  76.   int line (void) { return line_num; }
  77.   int column (void) { return column_num; }
  78.  
  79.   string text (void);
  80.   double number (void);
  81.   end_tok_type ettype (void);
  82.   plot_tok_type pttype (void);
  83.   symbol_record *sym_rec (void);
  84.  
  85.   string text_rep (void);
  86.  
  87. private:
  88.   token (const token& tok);
  89.   token& operator = (const token& tok);
  90.  
  91.   int line_num;
  92.   int column_num;
  93.   token_type type_tag;
  94.   union
  95.     {
  96.       string *str;
  97.       double num;
  98.       end_tok_type et;
  99.       plot_tok_type pt;
  100.       symbol_record *sr;
  101.     };
  102.   string orig_text;
  103. };
  104.  
  105. #endif
  106.  
  107. /*
  108. ;;; Local Variables: ***
  109. ;;; mode: C++ ***
  110. ;;; End: ***
  111. */
  112.